package cn.lingyangwl.agile.system.assembly;

import cn.lingyangwl.agile.system.model.entity.SysMenu;
import cn.lingyangwl.agile.system.model.entity.SysMenuRule;
import cn.lingyangwl.agile.system.model.rqrs.menu.*;
import cn.lingyangwl.agile.system.model.rqrs.role.RolePermResp;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * @author shenguangyang
 */
@Mapper(componentModel = "spring")
public interface SysMenuAssembly {
    SysMenuAssembly INSTANCE = Mappers.getMapper(SysMenuAssembly.class);

    SysMenu toMenu(MenuTreeResp source);

    SysMenu toMenu(MenuListReq source);

    @Mappings({
            @Mapping(source = "permissionId", target = "menuId")
    })
    SysMenuRule toMenuRule(MenuDataRuleListReq source);

    @Mappings({
            @Mapping(source = "permissionId", target = "menuId")
    })
    SysMenuRule toMenuRule(MenuDataRuleSaveReq source);

    @Mappings({
            @Mapping(source = "name", target = "describe"),
            @Mapping(source = "perms", target = "action"),
            @Mapping(source = "permsType", target = "type"),
            @Mapping(source = "status", target = "status"),
    })
    MenuAllAuthResp toAllAuthResp(SysMenu source);

    @Mappings({
            @Mapping(source = "id", target = "menuId")
    })
    RolePermResp toRolePermResp(SysMenu source);

    @Mappings({
            @Mapping(source = "id", target = "key"),
            @Mapping(source = "id", target = "value"),
            @Mapping(source = "name", target = "slotTitle"),
    })
    MenuTreeResp toMenuTreeResp(SysMenu source);
}
